package cn.lsh.util;

import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import org.apache.hadoop.io.IOUtils;

import java.io.InputStream;
import java.net.URL;

public class HdfsUtil {

	static {
		//设置通过FsUrlStreamHandlerFactory实例调用java.net.URL对象
		URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
	}

	public static void test(String url) throws Exception {
		InputStream inputStream = null;
		try {
			inputStream = new URL(url).openStream();
			IOUtils.copyBytes(inputStream, System.out, 4096, false);
		} finally {
			IOUtils.closeStream(inputStream);
		}
	}




}
